package com.alibaba.nacos.plugin.oracle.utils;

/**
 * The mysql implementation of ConfigInfoAggrMapper.
 *
 * @author hyx
 */
public class OracleSqlPaginationUtil {

    /**
     * 生成分页 SQL 查询.
     *
     * @param sql      原始 SQL 查询
     * @param startRow 起始行号（从 1 开始）
     * @param pageSize 结束行号
     * @return 分页后的 SQL 查询
     */
    public static String getPagedSql(String sql, int startRow, int pageSize) {
        return "SELECT * FROM ("
                + "  SELECT TMP_PAGE.*, ROWNUM rnum FROM ("
                + "    " + sql + " "
                + "  ) TMP_PAGE "
                + ") WHERE rnum >= "
                + startRow + " and rnum <= " + pageSize;
    }

}